package com.ruoyi.reservoir.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.reservoir.domain.Image;
import com.ruoyi.reservoir.domain.vo.AreaInfoVo;
import com.ruoyi.reservoir.domain.vo.ImageTimeAxisVo;
import com.ruoyi.reservoir.domain.vo.TimeSequenceAreaVo;
import com.ruoyi.reservoir.service.IImageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@SaIgnore
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/image")
public class ImageController {

    private final IImageService imageService;

    @GetMapping("/list")
    public R<?> list(){
        return R.ok(imageService.list());
    }

    /**
     * 获取首页驾驶舱影像时间轴列表接口
     * @return
     */
    @GetMapping("/imageTimeAxis")
    public R<?> imageTimeAxis(){

        List<ImageTimeAxisVo> result = imageService.getImageTimeAxis();

        return R.ok(result);
    }

    /**
     * 获取首页面积当期分析结果接口
     * @param id
     * @return
     */
    @GetMapping("/getAreaByImageId")
    public R<?> getAreaByImageId(@RequestParam(name = "id") String id){

        Image image = imageService.getById(id);


        return R.ok(BeanUtil.toBean(image, AreaInfoVo.class));
    }

    /**
     * 获取首页面积时序分析统计结果接口
     * @return
     */
    @GetMapping("timeSequenceArea")
    public R<?> getTimeSequenceArea(){

        TimeSequenceAreaVo result = imageService.getTimeSequenceArea();

        return R.ok(result);
    }
}
